//
//  HotFirstTableViewCell.m
//  WangI
//
//  Created by dllo on 15/11/24.
//  Copyright © 2015年 WJN. All rights reserved.
//

#import "HotFirstTableViewCell.h"

@implementation HotFirstTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.leftImage];
        [_leftImage release];
        [self addSubview:self.titleLabel];
        [_titleLabel release];
        [self addSubview:self.sourceLabel];
        [_sourceLabel release];
    }
    return self;
}

- (void)layoutSubviews {
    self.leftImage.frame = CGRectMake(5, 5, self.frame.size.width / 5, self.frame.size.height - 10);
    self.titleLabel.frame = CGRectMake(self.leftImage.right + 5, 5, self.width - self.leftImage.width - 10, self.leftImage.height / 3);
    self.sourceLabel.frame = CGRectMake(self.titleLabel.left, self.titleLabel.bottom + 20, self.titleLabel.width, self.leftImage.height - self.titleLabel.height - 20);
}

- (void)setHotModel:(HotModel *)hotModel {
    if (_hotModel != hotModel) {
        [_hotModel release];
        _hotModel = [hotModel retain];
    }
    [self.leftImage sd_setImageWithURL:[NSURL URLWithString:_hotModel.imgsrc]];
    self.titleLabel.text = _hotModel.title;
    self.sourceLabel.text = _hotModel.source;
}




- (UIImageView *)leftImage {
    if (!_leftImage) {
        self.leftImage = [[UIImageView alloc] initWithFrame:CGRectZero];
    }
    return _leftImage;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _titleLabel.numberOfLines = 0;
    }
    return _titleLabel;
}

- (UILabel *)sourceLabel {
    if (!_sourceLabel) {
        self.sourceLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _sourceLabel.font = [UIFont systemFontOfSize:12];
        _sourceLabel.textColor = [UIColor grayColor];
    }
    return _sourceLabel;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
